package com.servlet;

import com.dao.imp.AddUpdDelDaoImp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/11/24 17:58
 **/

@WebServlet(name = "UploadGoodServlet", value = "/UploadGoodServlet")
public class UploadGoodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        int id = Integer.parseInt(request.getParameter("id"));
        String subtitle = request.getParameter("subtitle");
        int price = Integer.parseInt(request.getParameter("price"));
        int stock = Integer.parseInt(request.getParameter("stock"));
        String parentId = request.getParameter("parentId");
        String childId = request.getParameter("childId");
        String detail = request.getParameter("detail");

        String sql = "UPDATE goods  SET good_name = '"+name+"', good_information = '"+detail+"', good_price = "+price+", good_remainingAmont = "+stock+", good_parentType = '"+parentId+"', good_childType = '"+childId+"', subtitle = '"+subtitle+"' WHERE good_id = "+id;
//        System.out.println(sql);
        AddUpdDelDaoImp addUpdDelDaoImp = new AddUpdDelDaoImp();
        addUpdDelDaoImp.addUpdDelGoods(sql);
    }
}
